<?php

// Copyright 2019 Hackware SpA <human@hackware.cl>
// "Hackware Web Services Core" is released under the MIT License terms.

namespace Hawese\Core\Exceptions;

use Illuminate\Validation\ValidationException;

class ModelValidationException extends ValidationException
{
    private $detail = [];

    public function __construct(string $model, ...$params)
    {
        parent::__construct(...$params);

        $this->message = 'Failed attribute validation';
        $this->code = 1;

        $this->detail = [
            'model' => $model,
            'attributes' => $this->errors()
        ];
    }

    public function getDetail()
    {
        return $this->detail;
    }
}
